// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov  Date: 2008-7-11 22:35:24
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   ConfigPlugIn.java

package com.creawor.imei.config;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.apache.log4j.Category;
import org.apache.log4j.PropertyConfigurator;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.PlugIn;
import org.apache.struts.config.ModuleConfig;

// Referenced classes of package com.creawor.imei.config:
//            ConfigXML, Config

public final class ConfigPlugIn
    implements PlugIn
{

    public ConfigPlugIn()
    {
        database = null;
        servlet = null;
        pathname = "/WEB-INF/imei-config.xml";
    }

    public String getPathname()
    {
        return pathname;
    }

    public void setPathname(String pathname)
    {
        this.pathname = pathname;
    }

    public void destroy()
    {
        database = null;
        servlet = null;
        database = null;
    }

    public void init(ActionServlet servlet, ModuleConfig config)
        throws ServletException
    {
        this.servlet = servlet;
        database = new ConfigXML();
        try
        {
            String path = calculatePath();
            PropertyConfigurator.configure(path);
            database.setPathname(path);
            database.open();
            java.util.HashMap ht = database.getHashMap();
            java.util.List list = database.getList();
            servlet.getServletContext().setAttribute("hashmap_config_48945", ht);
            servlet.getServletContext().setAttribute("list_config_kjdfjkdkj", list);
            Config.setHashMap(ht);
            cat.info("Initializing imei config file plug in from '/WEB-INF/imei-config.xml' successfully!");
        }
        catch(Exception e)
        {
            cat.error((new StringBuilder(" init the config file error: ")).append(e.getMessage()).toString());
            throw new ServletException((new StringBuilder("Cannot load config XML from [")).append(pathname).append("]").toString(), e);
        }
    }

    private String calculatePath()
        throws Exception
    {
        String path = servlet.getServletContext().getRealPath(pathname);
        return path;
    }

    public static final String HASHMAP_CONFIG = "hashmap_config_48945";
    public static final String LIST_CONFIG = "list_config_kjdfjkdkj";
    private ConfigXML database;
    private ActionServlet servlet;
    private String pathname;
    static Category cat = Category.getInstance(com.creawor.imei.config.ConfigPlugIn.class.getName());
    static Class class$0;

}